import {request,BASEURL} from "./request";

//上传图片
export const uploadImage = (fileBinary, fileType = 'image') => {
	uni.showLoading({
		title:'上传中...'
	})
	return new Promise(resolve => {
		let key = uni.getStorageSync('key');
		uni.uploadFile({
			header:{
				Accept:uni.getStorageSync('token')
			},
			url: BASEURL +'/api/index/upload?user_id=' + uni.getStorageSync('userId'),
			formData:{
				user_id: uni.getStorageSync('userId'),
			},
			filePath: fileBinary,
			name: 'file',
			success: res => {
				uni.hideLoading();
				resolve(JSON.parse(res.data).file_path)
			}
		})
	})
}

//手机号登录
export function getphone(data={}) {
	return request({
		url: 'index/getphone',
		method: 'GET',
		data,
	})
}

//比赛列表
export function gamelist(data={}) {
	return request({
		url: 'index/gamelist',
		method: 'GET',
		data,
	})
}
//比赛详情
export function gameDetail(data={}) {
	return request({
		url: 'index/gameDetail',
		method: 'GET',
		data,
	})
}
//排名
export function paiming(data={}) {
	return request({
		url: 'index/paiming',
		method: 'GET',
		data,
	})
}
//个人中心
export function my(data={}) {
	return request({
		url: 'index/my',
		method: 'GET',
		data,
	})
}
//比赛历史
export function history(data={}) {
	return request({
		url: 'index/history',
		method: 'GET',
		data,
	})
}
//修改用户头像昵称
export function saveUserInfo(data={}) {
	return request({
		url: 'index/saveUserInfo',
		method: 'POST',
		data,
	})
}
//获取选手信息
export function userDetail(data={}) {
	return request({
		url: 'index/userDetail',
		method: 'GET',
		data,
	})
}
